<template>
  <el-button-group>
    <el-button size="small" @click="viewAdmin">
      <el-icon><View /></el-icon>
    </el-button>
    <el-button size="small" type="primary" @click="editAdmin">
      <el-icon><Edit /></el-icon>
    </el-button>
    <el-button size="small" type="danger" @click="handleDelete">
      <el-icon><Delete /></el-icon>
    </el-button>
  </el-button-group>
</template>

<script setup>
import { useRouter } from 'vue-router';
import { ElMessageBox } from 'element-plus';
import { View, Edit, Delete } from '@element-plus/icons-vue';

const props = defineProps({
  row: Object
});

const router = useRouter();

const viewAdmin = () => {
  router.push(`/settings/admins/${props.row.id}`);
};

const editAdmin = () => {
  router.push(`/settings/admins/update/${props.row.id}`);
};

const handleDelete = () => {
  ElMessageBox.confirm("确定要删除这个管理员吗？", "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      // 调用删除用户的逻辑
    })
    .catch(() => {
      // 取消删除
    });
};
</script>
